package sys.charts;

import java.util.ArrayList;
import java.util.List;

public class ChartFactory {
	public static BarChart getBarChart(Title title,List<String> legendList,
			List<String> boxList,List<String> xData,List<Series> seriesList) {
		BarChart bar = new BarChart();
		//设置标题
		bar.setTitle(title);				
		//设置提示
		Tooltip tooltip = new Tooltip();
		tooltip.setTrigger("axis");
		bar.setTooltip(tooltip);
		//设置图例
		Legend legend = new Legend();
		legend.setData(legendList);
		bar.setLegend(legend);
		//设置工具栏
		Toolbox toolbox = new Toolbox();
		toolbox.setShow(true);
		Feature feature = new Feature();
		DataView dataView = new DataView(); 
		dataView.setReadOnly(true);
		dataView.setShow(true);
		feature.setDataView(dataView);
		MagicType magicType = new MagicType();
		magicType.setShow(true);
		magicType.setType(boxList);
		feature.setMagicType(magicType);
		Restore restore = new Restore();
		restore.setShow(false);
		feature.setRestore(restore);
		SaveAsImage saveAsImage = new SaveAsImage();
		saveAsImage.setShow(true);
		feature.setSaveAsImage(saveAsImage);
		toolbox.setFeature(feature);
		bar.setToolbox(toolbox);
		//设置X轴
		List<XAxis> xlist = new ArrayList<XAxis>();
		XAxis xAxis = new XAxis();
		xAxis.setType("category");
		xAxis.setData(xData);
		xlist.add(xAxis);
		bar.setXAxis(xlist);
		//设置Y轴
		List<YAxis> ylist = new ArrayList<YAxis>();
		YAxis yAxis = new YAxis();
		yAxis.setType("value");
		ylist.add(yAxis);
		bar.setYAxis(ylist);
		//设置数据		
		bar.setSeries(seriesList);	
		return bar;
	}
}
